import Vue from 'vue'
import VueRouter from 'vue-router'
import Films from '../views/Films.vue'
import Cinemas from '../views/Cinemas.vue'
import Findinfos from '../views/Findinfos.vue'
import Myself from '../views/Myself.vue'
import Detail from '../views/Detail/Index.vue'

import NowPlaying from '@/views/Films/NowPlaying.vue'
import ComingSoon from '@/views/Films/ComingSoon.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Films',
    component: Films
  }
  ,
  {
    path: '/films',
    // name: 'Films',
    component: Films,
    children:[
      {
        path:'NowPlaying',
        component:NowPlaying
      },
      {
        path:'ComingSoon',
        component:ComingSoon
      },
      {
        path:'',
        redirect:'/films/NowPlaying'
      }
    ]
  },
  {
    path: '/cinemas',
    name: 'Cinemas',
    component: Cinemas
  },
  {
    path: '/findinfos',
    name: 'Findinfos',
    component: Findinfos
  },
  {
    path: '/myself',
    name: 'Myself',
    component: Myself
  },
  {
    // 动态路由
    path: '/Detail/:id',
    name: 'MyDetal',
    component: Detail,
    props:true
  },
]

const router = new VueRouter({
  routes
})

router.beforeEach(
  (to,from,next)=>{
    // console.log('to=',to);
    // console.log('from=',from);
    next()
  }
)

export default router
